home *** CD-ROM | disk | FTP | other *** search
- /*
- File: serialboxShell.c
-
- Contains: Wrapper for serial box driver
-
- Version: xxx put version here xxx
-
- Copyright: © 1998 by Apple Computer, Inc., all rights reserved.
-
- */
-
-
- #include <Types.h>
- #include <Devices.h>
- #include <DriverServices.h>
- #include <USB.h>
- #include "ShimSerialInternal.h"
- #include "SerialBox.h"
-
- //------------------------------------------------------
- //
- // Globals
- //
- //------------------------------------------------------
-
-
- ShimSerialGlobals* gGlobals;
-
-
- //------------------------------------------------------
- //
- // Protos
- //
- //------------------------------------------------------
- static OSStatus SerialBoxValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc);
- static OSStatus serialBoxInitInterface(
- UInt32 interfaceNum,
- USBInterfaceDescriptor *interfaceDesc,
- USBDeviceDescriptor *deviceDesc,
- USBDeviceRef device);
- static OSStatus serialBoxInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc,
- UInt32 busPowerAvailable);
- static OSStatus serialBoxFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc);
- static OSStatus ExpertEntryProc(ExpertNotificationProcPtr pExpertNotify);
- static OSStatus serialBoxNotifyProc(UInt32 notification, void *pointer);
-
-
- //------------------------------------------------------
- //
- // This is the driver description structure that the expert looks for first.
- // If it's here, the information within is used to match the driver
- // to the device whose descriptor was passed to the expert.
- // Information in this block is also used by the expert when an
- // entry is created in the Name Registry.
- //
- //------------------------------------------------------
- USBDriverDescription TheUSBDriverDescription =
- {
- // Signature info
- kTheUSBDriverDescriptionSignature,
- kInitialUSBDriverDescriptor,
-
- // Device Info
- // 0x4C1, 0x3021, // vendor = USR 56K modem
- 0x565, 1, // vendor = Peracom USB to Serial Converter
- // 0x56c, 7, // vendor = e-Tek Labs/serial box
- 0, // version of product = not device specific
- 0, // protocol = not device specific
-
- // Interface Info (* I don't think this would always be required...*)
- 0, // Configuration Value
- 0, // Interface Number
- 0, // Interface Class
- 0, // Interface SubClass
- 0, // Interface Protocol
-
-
- // Driver Info
- "\pSerialBox", // Driver name for Name Registry
- 0, // Device Class (from USBDeviceDefines.h)
- 0, // Device Subclass
- 0x0, 0x0, 0x20, 0x1, // version of driver = 0.0d1
-
- // Driver Loading Info
- kUSBDoNotMatchGenericDevice // Flags
- };
-
-
- USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
- {
- kClassDriverPluginVersion, // Version of this structure
- SerialBoxValidateHW, // Hardware Validation Procedure
- serialBoxInitialize, // Initialization Procedure
- serialBoxInitInterface, // Interface Initialization Procedure
- serialBoxFinalize, // Finalization Procedure
- serialBoxNotifyProc,
- };
-
- // Hardware Validation
- // Called upon load by Expert
- static OSStatus SerialBoxValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc)
- {
- device = 0;
- desc = 0;
- return (OSStatus)noErr;
- }
-
-
- // Initialization function
- // Called upon load by Expert
- static OSStatus serialBoxInitialize(USBDeviceRef device, USBDeviceDescriptorPtr deviceDesc,
- UInt32 busPowerAvailable)
- {
- #pragma unused (busPowerAvailable)
- gGlobals = (ShimSerialGlobals*)PoolAllocateResident(sizeof(ShimSerialGlobals),true);
- if (gGlobals == NULL)
- goto bail;
-
- serialBoxEntry(device, deviceDesc);
-
- // Install Device Control Entry for both the ".In" and ".Out functions that are
- // requied for a serial driver which is what we are.
- if (noErr != InstallDriverControlEntries())
- {
- SysDebugStr("\pCan't install DCEs!");
- goto bail;
- }
-
- return (OSStatus)noErr;
-
- bail:
- if (gGlobals)
- PoolDeallocate(gGlobals);
- gGlobals = NULL;
-
- return (OSStatus)openErr;
- }
-
- // hubDriverInitInterface function
- // Called to initialize driver for an individual interface - either by expert or
- // internally by driver
- static OSStatus serialBoxInitInterface(
- UInt32 interfaceNum,
- USBInterfaceDescriptor *interfaceDesc,
- USBDeviceDescriptor *deviceDesc,
- USBDeviceRef device)
- {
- #pragma unused (interfaceNum)
- #pragma unused (interfaceDesc)
-
- if (gGlobals == NULL)
- gGlobals = (ShimSerialGlobals*)PoolAllocateResident(sizeof(ShimSerialGlobals),true);
-
- if (gGlobals == NULL)
- goto bail;
-
- serialBoxEntry(device, deviceDesc);
-
- // Install Device Control Entry for both the ".In" and ".Out functions that are
- // requied for a serial driver which is what we are.
- if (noErr != InstallDriverControlEntries())
- {
- SysDebugStr("\pCan't install DCEs!");
- goto bail;
- }
-
- return (OSStatus)noErr;
-
- bail:
- if (gGlobals)
- PoolDeallocate(gGlobals);
- gGlobals = NULL;
-
- return (OSStatus)openErr;
- }
-
- // Termination function
- // Called by Expert when driver is being shut down
- static OSStatus serialBoxFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc)
- {
- device = 0;
- pDesc = 0;
-
- KillUSBIO();
-
- RemoveDriverControlEntries();
-
- return (OSStatus)noErr;
- }
-
- static OSStatus ExpertEntryProc(ExpertNotificationProcPtr pExpertNotify)
- {
- pExpertNotify = 0;
- // ExpertNotify(pExpertNotify);
- return(noErr);
- }
-
- static OSStatus serialBoxNotifyProc(UInt32 notification, void *pointer)
- {
- #pragma unused (pointer)
-
- notification = 0;
- return(noErr);
- }
-
-